package date;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
 * 读文件
 * @author HXZY
 *
 */
public class Demo3 {

	public static void main(String[] args) throws IOException {
		File f=new File("E:\\aa.txt");
		try{
			FileInputStream fis=new FileInputStream(f);
			/*int x;
			while((x=fis.read())!=-1){
				System.out.print((char)x);
				
			}*/
			byte[] tmp=new byte[5];
			int c;
			while((c=fis.read(tmp))!=-1){
				//System.out.println(c+"====");
				System.out.println("\n还剩下"+fis.available()+"字节");
				for(int i=0;i<c;i++)
					System.out.print((char)tmp[i]);
				
			}
			fis.close();
			
		}catch(FileNotFoundException e){
			System.out.println("文件不存在！");
			
		}catch(IOException e){
			e.printStackTrace();
		}
		
	}
	

}
